package com.lwm.mybatis.custom.pojo;

import com.lwm.mybatis.custom.dao.UserDAO;
import lombok.Data;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.util.Arrays;

/**
 * @author liweimin
 * @date 2021/6/15 15:14
 * @since
 */
@Data
public class User implements Serializable {
    private Integer id;
    private String username;
    private LocalDateTime birthday;
    private String sex;
    private String address;

    public static void main(String[] args) {
        Class clazz = UserDAO.class;
        Method[] methods = clazz.getMethods();
        System.out.println("UserDAO的所有公共方法" + Arrays.toString(methods));
        Method[] declaredMethods = clazz.getDeclaredMethods();
        System.out.println("UserDAO的所有方法(不包含继承)" + Arrays.toString(declaredMethods));

        for (Method method : methods) {
            Type genericReturnType = method.getGenericReturnType();
            System.out.println(method.getName() + "方法返回参数：" + genericReturnType);
            if (genericReturnType instanceof ParameterizedType) {
                System.out.println(Arrays.toString(((ParameterizedType) genericReturnType).getActualTypeArguments()));
            }

        }
    }
}
